// packageB/pages/passwordVerify/passwordVerify.js
import {
    showMsg
  } from "../../utils/config";
  import {
    reqCheckUsername
  } from '../../request/api.js';

  var app = getApp()
  Page({
    data: {
      navHeight: app.globalData.navHeight + 'px', //头部距离
      type: true,
      username: '',
      password: ''
    },
    onLoad() {
      this.setData({
        username: wx.getStorageSync('mobile'),
      })
    },
    clearUsername() {
      this.setData({
        username: ''
      })
    },
    clearPassword() {
      this.setData({
        password: ''
      })
    },
    onClickIcon() {
      this.setData({
        type: !this.data.type,
      })
    },
    inputUsername(e) {
      this.setData({
        username: e.detail
      })
    },
    inputPassword(e) {
      this.setData({
        password: e.detail
      })
    },
    async onNextPage() {
      if (!this.data.username) return showMsg('请输入用户名')
      if (!this.data.password) return showMsg('请输入密码')
      let res = await reqCheckUsername({
        username: this.data.username,
        password: this.data.password
      })
      console.log(res, "res");
      if (res.code !== 20000) return showMsg(res.message)
      if (res.data.result == 'true') {
        wx.navigateTo({
          url: '/pages/setNewPhone/setNewPhone',
        })
      } else {
        showMsg('密码与当前帐号密码不一致')
      }
    }
  })